{php}
    $firstrun = input('param.firstrun/d', 0);
    $admin_1664250329_arr = cookie('admin-1664250329-arr');
    $admin_1664250329_arr = json_decode($admin_1664250329_arr);
    if (1 == $firstrun) {
        $admin_1664250329_arr = null;
    }
{/php}
<div class="sidebar-second order-navBox">
    <ul id="accordion" class="accordion">
        {eq name="'ShopProduct@index'|is_check_access" value="1"}
        <li data-value="1" {if null === $admin_1664250329_arr || in_array(1, $admin_1664250329_arr)}class="open"{/if}>
            <a class="link">商品管理<i class="fa fa-angle-right"></i></a>
            <ul class="submenu" {if is_array($admin_1664250329_arr) && !in_array(1, $admin_1664250329_arr)}style="display: none;"{/if}>
                <li>
                    <a href='{:url("ShopProduct/index", ["query"=>1])}' {if condition="in_array($Request.param.a, ['index', 'add', 'edit'])"} class="current" {/if}>商品列表</a>
                </li>
                <li>
                    <a href='{:url("ShopProduct/arctype_index")}' {if condition="in_array($Request.param.a, ['arctype_index', 'arctype_add', 'arctype_edit','arctype_conf'])"} class="current" {/if}>分类管理</a>
                </li>
                <li>
                    <a href='{:url("ShopProduct/goods_label")}' {if condition="in_array($Request.param.a, ['goods_label'])"} class="current" {/if}>商品服务</a>
                </li>
            </ul>
        </li>
        {/eq}
    </ul>
</div>

<script>
    $(function() {

        openClose();

        $('#accordion > li > a.link').click(function() {
            var $this = $(this);
                $parent = $this.parent();
                $next = $this.next();
            $next.slideToggle();
            $parent.toggleClass('open');
            openClose();
        });

        function openClose()
        {
            var arr = [];
            var className = '';
            $('#accordion > li').each(function(index, item){
                className = " " + $(item).attr('class') + " ";
                if (-1 < className.indexOf(' open ')) {
                    arr.push($(item).data('value'));
                }
            });
            arr = JSON.stringify(arr);
            setCookies('admin-1664250329-arr', arr);
        }
    });
</script>